package com.enniswu.weitter.entity;

import android.os.Parcel;
import android.os.Parcelable;

import java.util.ArrayList;
import java.util.List;

public class User implements Parcelable {
    private int id;
    private String portrait;
    private String name;
    private int gender;
    private String synopsis;
    private List<Integer> following = new ArrayList<>(0);
    private List<Integer> followers = new ArrayList<>(0);

    public User() {
    }

    @Override
    public int hashCode() {
        return id;
    }

    @Override
    public boolean equals(Object obj) {
        return obj == this || obj instanceof User && id == ((User) obj).id;
    }

    @Override
    public String toString() {
        return "User{" +
                "portrait='" + portrait + '\'' +
                ", name='" + name + '\'' +
                ", gender=" + gender +
                ", synopsis='" + synopsis + '\'' +
                ", following=" + following +
                ", followers=" + followers +
                ", id=" + id +
                '}';
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getPortrait() {
        return portrait;
    }

    public void setPortrait(String portrait) {
        this.portrait = portrait;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getGender() {
        return gender;
    }

    public void setGender(int gender) {
        this.gender = gender;
    }

    public String getSynopsis() {
        return synopsis;
    }

    public void setSynopsis(String synopsis) {
        this.synopsis = synopsis;
    }

    public List<Integer> getFollowing() {
        return following;
    }

    public void setFollowing(List<Integer> following) {
        this.following = following;
    }

    public List<Integer> getFollowers() {
        return followers;
    }

    public void setFollowers(List<Integer> followers) {
        this.followers = followers;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(this.id);
        dest.writeString(this.portrait);
        dest.writeString(this.name);
        dest.writeInt(this.gender);
        dest.writeString(this.synopsis);
        dest.writeList(this.following);
        dest.writeList(this.followers);
    }

    protected User(Parcel in) {
        this.id = in.readInt();
        this.portrait = in.readString();
        this.name = in.readString();
        this.gender = in.readInt();
        this.synopsis = in.readString();
        this.following = new ArrayList<Integer>();
        in.readList(this.following, Integer.class.getClassLoader());
        this.followers = new ArrayList<Integer>();
        in.readList(this.followers, Integer.class.getClassLoader());
    }

    public static final Creator<User> CREATOR = new Creator<User>() {
        @Override
        public User createFromParcel(Parcel source) {
            return new User(source);
        }

        @Override
        public User[] newArray(int size) {
            return new User[size];
        }
    };
}
